//
//  ConversationTableViewCell.m
//  NewChat
//
//  Created by songKX on 16/3/18.
//  Copyright © 2016年 蓝鸥. All rights reserved.
//

#import "ConversationTableViewCell.h"

@implementation ConversationTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

+(instancetype)cellForTableView:(UITableView *)tableView{
    
    static NSString *identifer = @"ccell";
    ConversationTableViewCell *temp = [tableView dequeueReusableCellWithIdentifier:identifer];
    
    if (temp == nil) {
        
        
        temp = [[[NSBundle mainBundle] loadNibNamed:@"ConversationTableViewCell" owner:nil options:nil] firstObject];
        
    }
    return temp;
    
}



-(void)setMessageCellInfoWithConversation:(EMConversation *)conversation{
    
    
    
    
    id body = conversation.latestMessage.messageBodies[0];
    
    if ([body isKindOfClass:[EMTextMessageBody class]]) {
        EMTextMessageBody *textBody = body;
        self.detailInfoLabel.text = textBody.text;
        
        self.dateLabel.text = [SKXFriendManager timeStr:conversation.latestMessage.timestamp];
        
    }else if ([body isKindOfClass:[EMVoiceMessageBody class]]){
        EMVoiceMessageBody *voiceBody = body;
        self.detailInfoLabel.text = [voiceBody displayName];
        
        self.dateLabel.text = [SKXFriendManager timeStr:conversation.latestMessage.timestamp];
    }else if ([body isKindOfClass:[EMImageMessageBody class]]){
        EMImageMessageBody *imageBody = body;
        self.detailInfoLabel.text = [imageBody displayName];
        
        self.dateLabel.text = [SKXFriendManager timeStr:conversation.latestMessage.timestamp];
    }else{
        
        self.detailInfoLabel.text = @"没有更多信息";
        self.dateLabel.text = nil;
        
    }
    
    
}


@end
